{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Comms External",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "COMMS" ],
      "description" : "CMP categorisation of the job associated with this file."
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "EXTERNAL" ],
      "description" : "Sub-categorisation of the job"
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.1,
      "maximum" : 1.1,
      "description" : "The current version of the generic extract message."
    },
    "transmitDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "The data and time that this JSON was transmitted to the external system."
    },
    "target" : {
      "$ref" : "#/definitions/Target"
    },
    "isoCurrencyCode" : {
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9]+$",
      "minLength" : 3,
      "maxLength" : 3,
      "description" : "This indicates the currency that any fields that contain monetary amounts are in."
    },
    "comm" : {
      "$ref" : "#/definitions/Comm"
    }
  },
  "required" : [ "interfaceCategory", "interfaceType", "version", "transmitDateTime", "isoCurrencyCode" ],
  "definitions" : {
    "Target" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "code" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The code for the particular external target."
        },
        "description" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "This is a description of the target code. This describes he external system that we are sending this JSON to."
        }
      },
      "required" : [ "code", "description" ]
    },
    "Comm" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "commsRequestId" : {
          "type" : "integer",
          "minimum" : 1,
          "description" : "This is the unique id in CMP for this Comm Request."
        },
        "commsCode" : {
          "type" : "string",
          "maxLength" : 20,
          "description" : "The Comms Code"
        },
        "mergeDateTime" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "This indicates the date and time that the merge was performed."
        },
        "hierarchyEntity" : {
          "$ref" : "#/definitions/HierarchyEntity"
        },
        "currentServiceId" : {
          "type" : "string",
          "maxLength" : 26,
          "description" : "The value may be the original mobile number or in E164 format"
        },
        "parentServiceId" : {
          "type" : "string",
          "maxLength" : 26,
          "description" : "The value may be the original mobile number or in E164 format"
        },
        "oldestServiceId" : {
          "type" : "string",
          "maxLength" : 26,
          "description" : "The value may be the original mobile number or in E164 format"
        },
        "emailAddress" : {
          "type" : "string",
          "maxLength" : 70,
          "description" : "The email address."
        },
        "postalAddress" : {
          "$ref" : "#/definitions/PostalAddress",
          "description" : ""
        },
        "preferences" : {
          "$ref" : "#/definitions/Preference",
          "description" : ""
        },
        "fields" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/CommField"
          },
          "description" : ""
        }
      },
      "required" : [ "commsRequestId", "commsCode", "mergeDateTime", "postalAddress", "fields" ]
    },
    "HierarchyEntity" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "subscriptionId" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 99999999,
          "description" : "The subscription Number of the entity that the comms relates to."
        },
        "accountId" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 99999999,
          "description" : "The account Number of the entity that the comms relates to."
        },
        "corporateId" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 6,
          "description" : "The corporate Code of the entity that the comms relates to."
        },
        "groupId" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 6,
          "description" : " The group Code of the entity that the comms relates to."
        }
      }
    },
    "PostalAddress" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "title" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The title of the customer e.g. Mr, Mrs etc"
        },
        "foreName" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "The customers first name"
        },
        "middleName" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The customers middle name"
        },
        "surname" : {
          "type" : "string",
          "maxLength" : 25,
          "description" : "The customers surname."
        },
        "companyName" : {
          "type" : "string",
          "maxLength" : 60,
          "description" : "The name of hte company. Only applicable when the address is stored as a company address in CMP."
        },
        "postCode" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The customer's post code."
        },
        "addressLines" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AddressLine"
          },
          "description" : "Lines of the address."
        }
      }
    },
    "AddressLine" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "line" : {
          "type" : "string",
          "maxLength" : 40,
          "description" : ""
        }
      }
    },
    "Preference" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "language" : {
          "type" : "string",
          "maxLength" : 3,
          "description" : "The preferred language of the customer."
        },
        "commsDeliveryMethodCode" : {
          "type" : "string",
          "enum" : [ "LETTER", "EMAIL", "PUSH", "SMS", "EXTERNAL", "ONLINE" ],
          "description" : "These are the complete list of comms delivery methods that CMP supports however the particular delivery methods that are used for any given CMP implementation may vary."
        },
        "particularRequirement" : {
          "type" : "string",
          "maxLength" : 3,
          "description" : "This indicates whether the subscriber has any specific requirements and/or special needs."
        }
      }
    },
    "CommField" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "name" : {
          "type" : "string",
          "description" : "Unique identifier for the field."
        },
        "value" : {
          "type" : "string",
          "description" : "A text value for the field."
        },
        "dateTimeValue" : {
          "type" : "string",
          "maxLength" : 10,
          "format" : "date-time",
          "description" : "A datetime value for the comms field."
        },
        "monetaryValue" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : "A monetary amount."
        }
      }
    }
  }
}